Function Reference

_GUICtrlEditLineIndex

Retrieves the character index of the first character of a specified line in a multiline edit control.

#Include <GuiEdit.au3>
_GUICtrlEditLineIndex($h_edit[, $i_line = -1])

 

Parameters

$h_edit control id/control hWnd
$i_line Optional: Specifies the zero-based line number.
A value of รป1 specifies the current line number (the line that contains the caret).

 

Return Value

Success: Returns the character index of the line specified in the $i_line parameter.
Failure: Returns $EC_ERR if the specified line number is greater than the number of lines in the edit control.

 

Remarks

None.

 

Related

_GUICtrlEditLineFromChar

 

Example


#include <GUIConstants.au3>
#include <GuiEdit.au3>

opt('MustDeclareVars', 1)

Dim $myedit, $Status, $msg, $Btn_GET

GUICreate("Edit Line Index", 392, 254)

$myedit = GUICtrlCreateEdit("First line" & @CRLF, 140, 32, 121, 97, BitOR($ES_AUTOVSCROLL, $WS_VSCROLL, $ES_MULTILINE))
GUICtrlSetLimit($myedit, 1500)
$Status = GUICtrlCreateLabel("", 0, 234, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))
$Btn_GET = GUICtrlCreateButton("Get", 150, 130, 90, 40, $BS_MULTILINE)

; will be append dont' forget 3rd parameter
GUICtrlSetData($myedit, "2nd line" & @CRLF & "3rd line" & @CRLF & "4th line" & @CRLF & _
        "5th line" & @CRLF & "6th line" & @CRLF & "7th line" & @CRLF & "8th line" & @CRLF & "9th line", 1)

GUISetState()

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Btn_GET
            Local $index = _GUICtrlEditLineIndex ($myedit)
            If ($index == $EC_ERR) Then
                GUICtrlSetData($Status, "Character Index: Invalid Index")
            Else
                GUICtrlSetData($Status, "Character Index: " & $index)
            EndIf
    EndSelect
WEnd